﻿@model  Tuple<User, List<Role>, List<Depart>> 
@{
    Layout = null;
}
 

<div class="layui-form" lay-filter="editForm" style="padding: 20px 30px 0 0;">
    <input type="hidden" name="id" value="@Model.Item1.Id" />
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="name" value="@Model.Item1.Name" lay-verify="required" maxlength="50" placeholder="请输入姓名" autocomplete="off" class="layui-input layui-form-danger">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">登录名</label>
        <div class="layui-input-inline">
            <input type="text" name="loginName" readonly value="@Model.Item1.LoginName" lay-verify="required" maxlength="50" placeholder="请输入登录名" autocomplete="off" class="layui-input layui-form-danger">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="password" name="pass" value="@Model.Item1.Pass" lay-verify="required" maxlength="50" placeholder="请输入密码" autocomplete="off" class="layui-input layui-form-danger">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">所属部门</label>
        <div class="layui-input-inline">
            <select name="DepartId">
                <option></option>
                @foreach (Depart item in Model.Item3)
                {
                    @if (item.Id.Equals(Model.Item1.DepartId))
                    {
                        <option value="@item.Id" selected>@item.Name</option>
                    }
                    else
                    {
                        <option value="@item.Id">@item.Name</option>
                    }

                }
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-block">
            @foreach (var role in Model.Item2)
            {
                <input type="checkbox" name="role" value="@role.Id" title="@role.RoleName" lay-skin="primary">
            }
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-inline">
            <input type="text" max="11" name="cellPhone" value="@Model.Item1.Cellphone" placeholder="请输入手机号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-inline">
            <input type="text" name="email" value="@Model.Item1.Email" placeholder="请输入邮箱" autocomplete="off" class="layui-input layui-form-danger">
        </div>
    </div>




    <div class="layui-form-item center">
        <input type="button" lay-submit="" lay-filter="edit" value="确认" class="layui-btn">
    </div>
</div>

<script>
    $.ajax({
        url: '/user/getRoleUser?id=@Model.Item1.Id',
        dataType:'json',
        success: function (res){
            for (var i = 0; i < res.length; i++) {
                console.log(res);
                var role = res[i];
                $('input[value="' + role.roleId+'"]').attr("checked", true);
            }
            form.render('checkbox');
        }
    });
</script>